package com.hxy.spring.service.impl;

import com.hxy.spring.bean.Employee;
import com.hxy.spring.bean.EmployeeExample;
import com.hxy.spring.mapper.EmployeeMapper;
import com.hxy.spring.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class EmployeeServiceImpl implements EmployeeService {
    @Autowired
    public EmployeeMapper employeeMapper;
    public List<Employee> findAllEmp(){
        return employeeMapper.selectByExample(null);
    }

    public List<Employee> findAllEmp1(EmployeeExample employeeExample) {
        return employeeMapper.selectByExample(employeeExample);
    }

    public int insert(Employee employee) {
        return employeeMapper.insertSelective(employee);
    }

    public int update(Employee employee) {
        return employeeMapper.updateByPrimaryKeySelective(employee);
    }

    public int del(Integer id) {
        return employeeMapper.deleteByPrimaryKey(id);
    }
}

